{header}
<div class="card">
  <div class="card-header">
    操作
  </div>
  <div class="card-body">
    <a class="btn btn-primary" href="add_topic" role="button">添加选题</a>
  </div>
</div>
<table class="table table-striped">
  <thead>
    <tr>
      <th scope="col">ID</th>
      <th scope="col">电影名称</th>
      <th scope="col">迅雷种子</th>
      <th scope="col">电影年份</th>
      <th scope="col">类型</th>
      <th scope="col" style="width: 200px;">操作</th>
    </tr>
  </thead>
  <tbody id="list">
    {tr}
  </tbody>
</table>
<script type="text/javascript">
  function remove(id) {
    layer.confirm('是否要删除该选题？<br>此操作将无法撤回', {icon: 2}, function () {
      $.ajax({
        url: '{base_url}library/remove_topic',
        type: 'post',
        data: {
          id: id
        },
        success: function (data) {
          var array = data.split(':');
          if (array.length !== 2) {
            layer.alert('系统错误：服务器返回非法值', {icon: 0});
          } else if (array[0] === 'fail') {
            layer.alert('删除失败，' + array[1], {icon: 0});
          } else if (array[0] === 'success') {
            location.reload();
          } else {
            layer.alert('服务器返回多余数据', {icon: 0});
            console.error(data);
          }
        },
        error: function (data) {
          layer.alert('删除失败', {icon: 0});
          console.error(data.responseText);
        }
      });
    }, null);
  }
</script>
{nav}
{footer}

